#include<iostream>
#include<cstdio>
int main()
{
	int n ;
	int max=0;
	int a[10001];

	int x ,y,score;
	scanf("%d" ,&n);

	for(int i=0 ;i<n ;i++){
		scanf("%d-%d %d",&x,&y,&score);
		a[x]+=score;
		if(a[x]>a[max]){
			max = x;
		}
	}
	printf("%d %d\n",max,a[max]);
}

